<% @media = media %>
<% if @media.mediable.processing_status.nil? %>
  This video is in the queue to be processed.
  <script type="text/javascript">
    //<![CDATA[
      movie_done = false;
    //]]>
  </script>
  <% unless secondrun %>
    <%= periodically_call_remote(:url => { :action => 'moviestatus', :id => @media.id, :secondrun => true}, :condition => "movie_done == false", :frequency => '2', :update => 'moviediv') %>
  <% end %>
<% elsif @media.mediable.processing_status == 200 %>
  <% if @media.mediable.quality == "high" %>
    <%= render :partial => "highres_playvideo", :locals => { :highres_video => "#{@media.mediable.public_filename}.mp4.flv", :video => "#{@media.mediable.public_filename}.flv", :image => "#{@media.mediable.public_filename}.jpg", :videoid => @media.id, :secondrun => secondrun } %>
  <% else %>
    <%= render :partial => "playvideo", :locals => { :video => "#{@media.mediable.public_filename}.flv", :image => "#{@media.mediable.public_filename}.jpg", :videoid => @media.id, :secondrun => secondrun } %>
  <% end %>
  <script type="text/javascript">
    //<![CDATA[
      movie_done = true;
    //]]>
  </script>
<% elsif @media.mediable.processing_status == 500 %>
  This video has errors and cannot be played.
  <script type="text/javascript">
    //<![CDATA[
      movie_done = true;
    //]]>
  </script>
<% elsif @media.mediable.processing_status == "" %>
  This video is in the queue to be processed.
  <script type="text/javascript">
    //<![CDATA[
      movie_done = false;
    //]]>
  </script>
  <% unless secondrun %>
    <%= periodically_call_remote(:url => { :action => 'moviestatus', :id => @media.id, :secondrun => true}, :condition => "movie_done == false", :frequency => '2', :update => 'moviediv') %>
  <% end %>
<% else %>
  This video is processing.  It is <%= @media.mediable.processing_status %>% complete.
  <div style="width: 400px; border: solid 1px #000; position: relative; margin-left: auto; margin-right: auto;">
    <div style="width: <%= @media.mediable.processing_status %>%; position: relative; height: 20px; background: #0000ff; color: #ffffff; text-align: center; padding-top: 2px; padding-bottom: 2px;"><%= @media.mediable.processing_status %>%</div>
  </div>
  <script type="text/javascript">
    //<![CDATA[
      movie_done = false;
    //]]>
  </script>
  <% unless secondrun %>
    <%= periodically_call_remote(:url => { :action => 'moviestatus', :id => @media.id, :secondrun => true}, :condition => "movie_done == false", :frequency => '2', :update => 'moviediv') %>
  <% end %>
<% end %>
